home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir30 / dt100.zip / INSTITLE.LSP < prev    next >
Lisp/Scheme  |  1993-09-26  |  39KB  |  1,421 lines

  1. ; DrafTools   [Version 1.00] 9/25/93       
  2. ;
  3. ; ***************************************
  4. ; ****  Author:  Owen Wengerd        ****
  5. ; ****                               ****
  6. ; ****  Manu-Soft Computer Services  ****
  7. ; ****  P.O. Box 84                  ****
  8. ; ****  Fredericksburg, OH  44627    ****
  9. ; ****  (216) 695-5903               ****
  10. ; ****  Compu-Serve ID:  71324,3252  ****
  11. ; ***************************************
  12.  
  13. (defun C:INSTITLE (/ 
  14.  
  15. ;*** Local Variables ***
  16.  
  17.   bdr 
  18.   ca 
  19.   dcl_id 
  20.   dlg_retcode 
  21.   errflag 
  22.   ia 
  23.   insert_method
  24.   ip 
  25.   last_focus 
  26.   olderr
  27.   oldvar 
  28.   pattern 
  29.   restore
  30.   scale 
  31.   scale1
  32.   scale2
  33.   scale_ID 
  34.   scale_list 
  35.   select_method 
  36.   t1 
  37.   tb_dir 
  38.   tb_file
  39.   tbd 
  40.   tblayer
  41.   tblocks_found
  42.   tbscales_path
  43.   xdos_loaded 
  44.  
  45.  
  46. ;*** Local Functions ***
  47.  
  48.   errexit
  49.   institlex
  50.   add_scale
  51.   as_accept
  52.   as_scale
  53.   as_scale_ID
  54.   change_path
  55.   check_bdr
  56.   check_layer
  57.   check_scale
  58.   clear_err
  59.   compare_name
  60.   delete_scale
  61.   dismiss_dialog
  62.   dlg_act
  63.   edit_scale
  64.   err
  65.   find_scale
  66.   fpath
  67.   get_attrib_value
  68.   get_default_ip
  69.   get_help
  70.   get_table
  71.   get_tblayer
  72.   get_tblock
  73.   get_values
  74.   is_visible
  75.   open_file
  76.   parse_path
  77.   put_border
  78.   remove_item
  79.   rtd
  80.   sort_list
  81.   sort_search
  82.   update_scale_file
  83.   update_tbfile
  84.   update_tbpath
  85.   valid_name
  86.   )
  87.  
  88. ;*** Local Functions ***
  89.  
  90. (defun errexit (s)
  91.   (if (= 8 (logand 8 (getvar "UNDOCTL"))) 
  92.     (command "UNDO" "E" "UNDO" 1)
  93.   )
  94.   (if (member s '("console break" "Function cancelled"))
  95.     (princ)    
  96.     (princ (strcat "\nError:  " s))
  97.   )
  98.   (restore)
  99. )
  100.  
  101. (defun institlex (/ t1)
  102.   (setvar "ATTDIA" (nth 1 oldvar))
  103.   (setvar "ATTMODE" (nth 2 oldvar))
  104.   (setvar "ATTREQ" (nth 3 oldvar))
  105.   (setvar "REGENMODE" (nth 4 oldvar))
  106.   (setvar "EXPERT" (nth 5 oldvar))
  107.   (setvar "CLAYER" (nth 6 oldvar))
  108.   (setvar "LUPREC" (nth 7 oldvar))
  109.   (if (/= 1 (setq t1 (logand 3 (nth 8 oldvar))))
  110.     (progn
  111.       (command "_UNDO")
  112.       (if (/= 0 (logand 3 (getvar "UNDOCTL"))) (command "_C"))
  113.       (command (if (= 0 t1) "_N" "_O"))
  114.     )
  115.   )
  116.   (if xdos_loaded
  117.     (progn
  118.       (dt_dossetdrv (- (ascii (strcase (nth 9 oldvar))) 64))
  119.       (dt_dossetdir (nth 9 oldvar))
  120.       (if (and (/= T xdos_loaded) (not (xunload "xdos_dt" nil)))
  121.         (princ "\n**Cannot unload XDOS_DT from memory**\n ")
  122.       )
  123.     )
  124.   )
  125.   (setvar "CMDECHO" (car oldvar))
  126.   (setq *error* olderr)
  127.   (princ)
  128. )
  129.  
  130. (defun rtd (a) (/ (* a 180.0) pi))
  131.  
  132. (defun dlg_act (key why value / t1)
  133.   (cond
  134.     ( (= key "replace")
  135.       (setq insert_method value)
  136.       (mode_tile (if errflag errflag last_focus) 2)
  137.     )
  138.     ( (= key "scale_select_method")
  139.       (setq select_method (= "1" value))
  140.       (if select_method
  141.         (progn 
  142.           (mode_tile "scale_ID" 0) 
  143.           (mode_tile "scale1" 1)
  144.           (mode_tile "scale2" 1)
  145.           (set_tile "scale1" 
  146.             (rtos (cadr (nth scale_ID scale_list)))
  147.           )
  148.           (set_tile "scale2" 
  149.             (rtos (caddr (nth scale_ID scale_list)))
  150.           )
  151.           (check_scale)
  152.           (mode_tile "scale_ID" 2)
  153.           (if (> scale_ID 0) 
  154.             (progn
  155.               (mode_tile "delete_scale" 0)
  156.               (mode_tile "edit_scale" 0)
  157.             )
  158.           )
  159.         )
  160.         (progn
  161.           (mode_tile "scale_ID" 1) 
  162.           (mode_tile "scale1" 0)
  163.           (mode_tile "scale2" 0)
  164.           (mode_tile "scale1" 2)
  165.           (mode_tile "edit_scale" 1)
  166.           (mode_tile "delete_scale" 1)
  167.         )
  168.       )
  169.     )
  170.     ( (and errflag (/= key errflag))
  171.     )
  172.     ( (= key "pattern")
  173.       (if (not (wcmatch value "*[] `#`@`~`[`,`'!%^&()+={}|`\\:;\"<>/]*"))
  174.         (progn
  175.           (setq pattern value) 
  176.           (update_tbfile)
  177.           (clear_err)
  178.         )
  179.         (err "Pattern contains an invalid character." "pattern")
  180.       )
  181.     )
  182.     ( (= key "scale_ID")
  183.       (set_tile "scale1" 
  184.         (rtos 
  185.           (cadr (nth (setq scale_ID (atoi value)) scale_list))
  186.         )
  187.       )
  188.       (set_tile "scale2" 
  189.         (rtos 
  190.           (caddr (nth scale_ID scale_list))
  191.         )
  192.       )
  193.       (if (= scale_ID 0) 
  194.         (progn (mode_tile "edit_scale" 1) (mode_tile "delete_scale" 1))
  195.         (progn (mode_tile "edit_scale" 0) (mode_tile "delete_scale" 0))
  196.       )
  197.       (check_scale)
  198.     )
  199.     ( (= key "scale1") (check_scale))
  200.     ( (= key "scale2") (check_scale))
  201.     ( (= key "border")
  202.       (setq bdr value)
  203.       (check_bdr bdr)
  204.     )
  205.     ( (= key "angle")   
  206.       (if (setq t1 (angtof (get_tile key)))
  207.         (progn
  208.           (setq ia t1)
  209.           (set_tile key (angtos t1))
  210.           (clear_err)
  211.         )
  212.         (err "Rotation angle must be a valid angle." key)
  213.       )
  214.     )
  215.     ( (member key '("x_ip" "y_ip" "z_ip"))
  216.       (if (numberp (setq t1 (distof value)))
  217.         (progn
  218.           (setq ip (subst t1 (nth (- (ascii key) 120) ip) ip))
  219.           (set_tile key (rtos t1))
  220.           (clear_err)
  221.         )
  222.         (err 
  223.           (strcat 
  224.             "Insertion Point "
  225.             (chr (- (ascii key) 32)) 
  226.             "-Coordinate must be a real number."
  227.           )
  228.           key
  229.         )
  230.       )
  231.     )
  232.  
  233.   )
  234.   (if errflag 
  235.     (mode_tile errflag 2)
  236.     (if (/= "replace" key) (setq last_focus key))
  237.   )
  238. )
  239.  
  240. (defun clear_err ()
  241.   (set_tile "error" "")
  242.   (setq errflag nil)
  243.   (if (/= "" bdr)
  244.     (progn
  245.       (mode_tile "accept" 0)
  246.       (mode_tile "preview" 0)
  247.     )
  248.   )
  249. )
  250.  
  251. (defun err (msg key)
  252.   (mode_tile "accept" 1)
  253.   (mode_tile "preview" 1)
  254.   (set_tile "error" msg)
  255.   (setq errflag key)
  256. )     
  257.  
  258. (defun is_visible (pt)
  259.   (if
  260.     (and
  261.       pt
  262.       (listp pt)
  263.       (<= 
  264.         (abs (- (car (getvar "VIEWCTR")) (car pt))) 
  265.         (* (getvar "VIEWSIZE") (apply '/ (getvar "SCREENSIZE")) 0.5)
  266.       )
  267.       (<=
  268.         (abs (- (cadr (getvar "VIEWCTR")) (cadr pt)))
  269.         (/ (getvar "VIEWSIZE") 2)
  270.       )
  271.     )
  272.     pt
  273.   )
  274. )
  275.  
  276. (defun get_default_ip (ss / cnt pt t1)
  277.   (if
  278.     (or
  279.       (and ss 
  280.         (if (= 1 (sslength ss)) 
  281.           (setq pt (cdr (assoc '10 (entget (ssname ss 0)))))
  282.           (progn
  283.             (setq cnt -1)
  284.             (while (< (setq cnt (1+ cnt)) (sslength ss)) 
  285.               (if
  286.                 (setq t1 
  287.                   (is_visible (cdr (assoc '10 (entget (ssname ss cnt)))))
  288.                 )
  289.                 (setq pt (cons t1 pt))
  290.               )
  291.             )
  292.             (setq pt (car pt))
  293.           )
  294.         )
  295.       )
  296.       (setq pt (is_visible '(0 0 0)))
  297.       (setq pt (is_visible (getvar "LASTPOINT")))
  298.     )
  299.     pt
  300.     (getvar "VIEWCTR")
  301.   )
  302. )
  303.  
  304. (defun compare_name (x y) (> (cdr (assoc '2 x)) (cdr (assoc '2 y))))
  305.  
  306. (defun sort_search (/ track)
  307.   (mapcar '(lambda (x) (and x (sfunc x track) (setq track x))) lst)
  308.   (setq lst (subst nil track lst))
  309.   track
  310. )
  311.  
  312. (defun sort_list (lst sfunc / tlst)
  313.   (while 
  314.     (apply 'or lst) 
  315.     (setq tlst (append tlst (list (sort_search))))
  316.   )
  317.   tlst
  318. )
  319.  
  320. (defun get_table (table / t1 t2)
  321.   (while (setq t1 (tblnext table (not t1))) (setq t2 (append t2 (list t1))))
  322.   t2
  323. )
  324.  
  325. (defun fpath (filename / path)
  326.   (if 
  327.     (and
  328.       *DT_PATH 
  329.       (setq path
  330.         (findfile 
  331.           (strcat 
  332.             *DT_PATH 
  333.             (if (= "\\" (substr *DT_PATH (strlen *DT_PATH) 1)) "" "\\") 
  334.             filename
  335.           )
  336.         )
  337.       )
  338.     )
  339.     path
  340.     (findfile filename)
  341.   )
  342. )
  343.  
  344. (defun get_help (/ help_path)
  345.   (if (setq help_path (fpath "INSTITLE.HLP"))
  346.     (acad_helpdlg help_path "")
  347.     (alert "Cannot locate help file 'INSTITLE.HLP'!")
  348.   )
  349.   (mode_tile (if errflag errflag last_focus) 2)
  350. )
  351.  
  352. (defun parse_path (name / ct)
  353.   (setq ct (strlen name))
  354.   (while (and (> ct 0) (/= "\\" (substr name ct 1))) (setq ct (1- ct)))
  355.   (if (> ct 0) (setq name (substr name ct)) name)
  356. )
  357.  
  358. (defun find_scale (scale / cnt t1)
  359.   (setq cnt (length scale_list))
  360.   (while 
  361.     (and 
  362.       (> (setq cnt (1- cnt)) 0)
  363.       (not 
  364.         (equal 
  365.           scale 
  366.           (/ (cadr (nth cnt scale_list)) (caddr (nth cnt scale_list)))
  367.           (expt 10.0 (- -1 (getvar "LUPREC")))
  368.         )
  369.       )
  370.     )
  371.   )
  372.   cnt
  373. )
  374.  
  375. (defun open_file (filename / path t1 t2)
  376.   (if (wcmatch filename "*[\\:]*") 
  377.     (if (setq t1 (findfile filename)) 
  378.       t1  
  379.       (if (setq t1 (open filename "w")) (progn (close t1) filename))
  380.     )
  381.     (if (setq t1 (fpath filename))
  382.       t1
  383.       (if
  384.         (setq t2
  385.           (open
  386.             (setq path
  387.               (strcat
  388.                 (if 
  389.                   (= 
  390.                     "\\"
  391.                     (substr 
  392.                       (setq t1 
  393.                         (if *DT_PATH *DT_PATH (dt_doscurdir))
  394.                       )
  395.                       (strlen t1) 
  396.                       1
  397.                     )
  398.                   )
  399.                   t1
  400.                   (strcat t1 "\\")
  401.                 )
  402.                 filename
  403.               )
  404.             )
  405.             "w"
  406.           )
  407.         )
  408.         (progn (close t2) path)
  409.       )
  410.     )
  411.   )
  412. )
  413.  
  414. (defun check_bdr (bdr)
  415.   (if (findfile (strcat tbd "\\" bdr))
  416.     (clear_err)
  417.     (if (= bdr "")
  418.       (progn 
  419.         (mode_tile "accept" 1) 
  420.         (mode_tile "preview" 1) 
  421.         (setq errflag nil)
  422.       )
  423.       (if (/= errflag "border")
  424.         (err "Specified Border Doesn't Exist" "border")
  425.       )
  426.     )
  427.   )
  428. )
  429.  
  430. (defun get_attrib_value (ent tag / ca t1 t2)
  431.   (while 
  432.     (and 
  433.       ent 
  434.       (not t2)
  435.       (setq ent (entnext ent))
  436.       (/= "SEQEND" (cdr (assoc '0 (setq t1 (entget ent '("TBLOCK"))))))
  437.     )
  438.     (if 
  439.       (and (= tag (cdr (assoc '2 t1))) (= "ATTRIB" (cdr (assoc '0 t1))))
  440.       (if 
  441.         (not
  442.           (setq t2
  443.             (cdr (assoc '1000 (cdr (assoc "TBLOCK" (cdr (assoc '-3 t1))))))
  444.           )
  445.         )
  446.         (setq t2 (cdr (assoc '1 t1)))
  447.       )          
  448.     )
  449.   )  
  450.   t2
  451. )
  452.  
  453. (defun get_values (/ t1)
  454.   (check_scale)
  455.   (setq *TBLAYER tblayer)
  456.   (setq ip 
  457.     (list 
  458.       (distof (get_tile "x_ip")) 
  459.       (distof (get_tile "y_ip")) 
  460.       (distof (get_tile "z_ip")) 
  461.     )
  462.   )
  463.   (setq insert_method (get_tile "replace"))
  464.   (setq tbd 
  465.     (progn
  466.       (setq tbd (get_tile "path"))
  467.       (if (= "\\" (substr tbd (strlen tbd) 1))
  468.         (substr tbd 1 (1- (strlen tbd)))
  469.         tbd
  470.       )
  471.     )
  472.   )
  473.   (setq bdr (get_tile "border"))
  474.   (check_bdr bdr)
  475.   (if (findfile (strcat tbd "\\" bdr))
  476.     (progn
  477.       (setq ia (angtof (get_tile "angle")))
  478.       (done_dialog 1)
  479.     )
  480.     (progn
  481.       (err 
  482.         (if (= "" bdr) 
  483.           "You Must Specify a Border."
  484.           "Specified Border Doesn't Exist"
  485.         )
  486.         "border"
  487.       )
  488.       (mode_tile "border" 2)
  489.       (mode_tile "border" 3)
  490.     )
  491.   )
  492. )
  493.  
  494. (defun update_tbpath ()
  495.   (start_list "tbdir")
  496.   (mapcar 'add_list 
  497.     (setq tb_dir 
  498.       (append 
  499.         '("\\")
  500.         (if 
  501.           (= "." (car (setq t1 (acad_strlsort (dt_dossubdir))))) 
  502.           (cdr t1) 
  503.           t1
  504.         )
  505.         (acad_strlsort 
  506.           (mapcar 
  507.             '(lambda (x) 
  508.               (strcat ">" (chr (+ 64 x)) ":")
  509.              ) 
  510.             (dt_dosdrv)
  511.           )
  512.         ) 
  513.       )
  514.     )
  515.   )
  516.   (end_list)
  517. )
  518.  
  519. (defun update_tbfile (/ t1)
  520.   (setq t1 (dt_dosdir pattern 0))
  521.   (start_list "tbfile")
  522.   (if t1 (mapcar 'add_list (setq tb_file (acad_strlsort t1))))
  523.   (end_list)
  524. )
  525.  
  526. (defun put_border (value)
  527.   (if (or (not errflag) (= errflag "border")) 
  528.     (progn
  529.       (set_tile "border" (setq bdr (nth (atoi value) tb_file)))
  530.       (check_bdr bdr)
  531.     )
  532.     (mode_tile errflag 2)
  533.   )
  534. )
  535.  
  536. (defun change_path (value / t1 drv dir)
  537.   (if (= errflag "border") 
  538.     (progn (setq bdr "") (set_tile "border" "") (clear_err))
  539.   )
  540.   (if errflag
  541.     (mode_tile errflag 2)
  542.     (progn
  543.       (setq dir (dt_doscurdir)
  544.             drv (dt_doscurdrv)
  545.       )
  546.       (if (= ">" (substr (setq t1 (nth (atoi value) tb_dir)) 1 1))  
  547.         (dt_dossetdrv (- (ascii (strcase (substr t1 2))) 64))
  548.         (dt_dossetdir t1)
  549.       )
  550.       (if (setq t1 (dt_doscurdir))
  551.         (progn
  552.           (setq tbd 
  553.             (progn
  554.               (set_tile "path" (setq tbd (strcase t1 '1)))
  555.               (if (= "\\" (substr tbd (strlen tbd) 1))
  556.                 (substr tbd 1 (1- (strlen tbd)))
  557.                 tbd
  558.               )
  559.             )
  560.           )
  561.           (update_tbpath)
  562.           (update_tbfile)
  563.           (check_bdr (get_tile "border"))
  564.         )
  565.         (progn
  566.           (dt_dossetdrv drv)
  567.           (dt_dossetdir dir)
  568.           (alert "          Drive Not Ready          ")
  569.         )
  570.       )
  571.     )
  572.   )
  573. )
  574.  
  575. (defun check_scale (/ t1)
  576.   (if (and (numberp (setq t1 (distof (get_tile "scale1")))) (> t1 0))
  577.     (progn
  578.       (set_tile "scale1" (rtos (setq scale1 t1)))
  579.       (clear_err)
  580.     )
  581.     (progn
  582.       (err "Scale must be a positive, non-zero number." "scale1")
  583.       (if select_method (edit_scale) (mode_tile "scale1" 2))
  584.     )
  585.   )
  586.   (if (and (numberp (setq t1 (distof (get_tile "scale2")))) (> t1 0))
  587.     (progn
  588.       (set_tile "scale2" (rtos (setq scale2 t1)))
  589.       (clear_err)
  590.     )
  591.     (progn
  592.       (err "Scale must be a positive, non-zero number." "scale2")
  593.       (if select_method (edit_scale) (mode_tile "scale2" 2))
  594.     )
  595.   )
  596.   (setq scale (/ scale1 scale2))
  597. )
  598.  
  599. (defun as_accept ()
  600.   (if (and s1 s2 sitem)
  601.     (dismiss_dialog 1)
  602.     (if (or (= errflag "scale1") (= errflag "scale2"))
  603.       (progn
  604.         (err "Scale must be a positive number." errflag)
  605.         (mode_tile errflag 2)
  606.       )
  607.       (progn
  608.         (err "Enter a description." "scale_ID")
  609.         (mode_tile errflag 2)
  610.       )
  611.     )
  612.   )
  613. )
  614.  
  615. (defun as_scale (value key)
  616.   (if (= errflag "scale_ID")
  617.     (mode_tile errflag 2)
  618.     (if 
  619.       (and 
  620.         (numberp (setq t1 (distof value))) 
  621.         (> t1 0)
  622.       )
  623.       (progn
  624.         (set (if (= key "scale1") 's1 's2) t1)
  625.         (if (= errflag key)
  626.           (progn
  627.             (set_tile "error" "")
  628.             (setq errflag nil)
  629.             (if (/= "< Default >" (get_tile "scale_ID")) 
  630.               (mode_tile "accept" 0)
  631.             )
  632.           )
  633.         )
  634.       )
  635.       (progn
  636.         (err
  637.           (if (> (strlen value) 0) 
  638.             "Scale must be a positive number." 
  639.             "Enter a scale factor."
  640.           )
  641.           key
  642.         )
  643.         (set (if (= key "scale1") 's1 's2) nil)
  644.         (mode_tile errflag 2)
  645.       )
  646.     )
  647.   )
  648. )
  649.  
  650. (defun as_scale_ID (value)
  651.   (if (or (= errflag "scale1") (= errflag "scale2"))
  652.     (mode_tile errflag 2)
  653.     (if (and (/= "< Default >" value) (> (strlen (setq sitem value)) 0))
  654.       (progn (set_tile "error" "") (setq errflag nil) (mode_tile "accept" 0))
  655.       (progn (setq sitem nil errflag nil) (set_tile "error" ""))
  656.     )
  657.   )
  658. )
  659.  
  660. (defun add_scale (/ sitem s1 s2 t1 t2)
  661.   (if (and errflag (/= errflag "border"))
  662.     (mode_tile errflag 2)
  663.     (if (new_dialog "SCALE_A" dcl_id)
  664.       (progn
  665.         (setq s1      (if select_method (cadr (car scale_list)) scale1)
  666.               s2      (if select_method (caddr (car scale_list)) scale2)
  667.               sitem   nil
  668.         )
  669.         (set_tile "scale_ID" (car (car scale_list)))
  670.         (set_tile "scale1" (rtos s1))
  671.         (set_tile "scale2" (rtos s2))
  672.         (action_tile "accept" "(as_accept)")
  673.         (action_tile "cancel" "(done_dialog 0)")
  674.         (action_tile "scale1" "(as_scale $value $key)")
  675.         (action_tile "scale2" "(as_scale $value $key)")
  676.         (action_tile "scale_ID" "(as_scale_ID $value)")
  677.         (mode_tile "accept" 1)
  678.         (if (= 1 (start_dialog))    
  679.           (progn  
  680.             (setq t1     (list (car scale_list))
  681.                   scale1 s1
  682.                   scale2 s2
  683.                   scale  (/ scale1 scale2)
  684.             )
  685.             (while 
  686.               (and
  687.                 (setq scale_list (cdr scale_list))
  688.                 (> 
  689.                   scale 
  690.                   (/ (cadr (car scale_list)) (caddr (car scale_list)))
  691.                 ) 
  692.               )
  693.               (setq t1 (append t1 (list (car scale_list))))
  694.             )
  695.             (setq t2 (itoa (setq scale_ID (length t1))))
  696.             (setq scale_list 
  697.               (append t1 (list (list sitem scale1 scale2)) scale_list)
  698.             )
  699.             (update_scale_file)
  700.             (start_list "scale_ID")
  701.             (foreach t1 scale_list (add_list (car t1)))
  702.             (end_list)
  703.             (set_tile "select_method" "1")  
  704.             (setq select_method (not nil))
  705.             (mode_tile "scale_ID" 0)
  706.             (mode_tile "scale1" 1)
  707.             (mode_tile "scale2" 1)
  708.             (set_tile "scale1" (rtos scale1))                  
  709.             (set_tile "scale2" (rtos scale2))                  
  710.             (set_tile "scale_ID" t2)
  711.             (mode_tile "scale_ID" 2)
  712.             (setq last_focus "scale_ID")
  713.             (mode_tile "edit_scale" 0)
  714.             (mode_tile "delete_scale" 0)
  715.           )
  716.           (if last_focus (mode_tile last_focus 2))
  717.         )
  718.       )
  719.       (err "Child Dialog Box 'SCALE_A' Cannot Initialize" "add_scale")
  720.     )
  721.   )
  722. )
  723.   
  724. (defun edit_scale (/ sitem s1 s2 t1 t2)
  725.   (if (and errflag (/= errflag "border"))
  726.     (mode_tile errflag 2)
  727.     (if (new_dialog "SCALE_E" dcl_id)
  728.       (progn
  729.         (setq s1      (cadr (nth scale_ID scale_list))
  730.               s2      (caddr (nth scale_ID scale_list))
  731.               sitem   (car (nth scale_ID scale_list))
  732.         )
  733.         (set_tile "scale_ID" sitem)
  734.         (set_tile "scale1" (rtos s1))
  735.         (set_tile "scale2" (rtos s2))
  736.         (action_tile "accept" "(as_accept)")
  737.         (action_tile "cancel" "(done_dialog 0)")
  738.         (action_tile "scale1" "(as_scale $value $key)")
  739.         (action_tile "scale2" "(as_scale $value $key)")
  740.         (action_tile "scale_ID" "(as_scale_ID $value)")
  741.         (if (= 1 (start_dialog))    
  742.           (progn  
  743.             (remove_item)
  744.             (setq t1     (list (car scale_list))
  745.                   scale1 s1
  746.                   scale2 s2
  747.                   scale  (/ scale1 scale2)
  748.             )
  749.             (while 
  750.               (and
  751.                 (setq scale_list (cdr scale_list))
  752.                 (> 
  753.                   scale 
  754.                   (/ (cadr (car scale_list)) (caddr (car scale_list)))
  755.                 ) 
  756.               )
  757.               (setq t1 (append t1 (list (car scale_list))))
  758.             )
  759.             (setq t2 (itoa (setq scale_ID (length t1))))
  760.             (setq scale_list 
  761.               (append t1 (list (list sitem s1 s2)) scale_list)
  762.             )
  763.             (update_scale_file)
  764.             (start_list "scale_ID")
  765.             (foreach t1 scale_list (add_list (car t1)))
  766.             (end_list)
  767.             (set_tile "select_method" "1")  
  768.             (setq select_method (not nil))
  769.             (set_tile "scale1" (rtos scale1))                  
  770.             (set_tile "scale2" (rtos scale2))                  
  771.             (set_tile "scale_ID" t2)
  772.             (mode_tile "scale_ID" 2)
  773.             (setq last_focus "scale_ID")
  774.             (mode_tile "edit_scale" 0)
  775.             (mode_tile "delete_scale" 0)
  776.           )
  777.           (if last_focus (mode_tile last_focus 2))
  778.         )
  779.       )
  780.       (err "Child Dialog Box 'SCALE_E' Cannot Initialize" "edit_scale")
  781.     )
  782.   )
  783. )
  784.   
  785. (defun remove_item (/ t1 cnt)
  786.   (setq cnt (1- (length scale_list)))
  787.   (while (>= cnt 0) 
  788.     (progn 
  789.       (if (/= cnt scale_ID) (setq t1 (cons (nth cnt scale_list) t1))) 
  790.       (setq cnt (1- cnt))
  791.     )
  792.   )
  793.   (setq scale_list t1)
  794. )
  795.  
  796. (defun delete_scale (/ t1)
  797.   (if (and errflag (/= errflag "border"))
  798.     (mode_tile errflag 2)
  799.     (if (new_dialog "SCALE_D" dcl_id)
  800.       (progn
  801.         (action_tile "delete" "(done_dialog 1)")
  802.         (action_tile "cancel" "(done_dialog 0)")
  803.         (if (= 1 (start_dialog))
  804.           (progn
  805.             (remove_item)
  806.             (update_scale_file)
  807.             (start_list "scale_ID")
  808.             (foreach t1 scale_list (add_list (car t1)))
  809.             (end_list)
  810.             (setq scale_ID (1- scale_ID))
  811.             (set_tile "scale_ID" (itoa scale_ID))
  812.             (setq scale 
  813.               (/ 
  814.                 (setq scale1 (cadr (nth scale_ID scale_list)))
  815.                 (setq scale2 (caddr (nth scale_ID scale_list)))
  816.               )
  817.             )
  818.             (set_tile "scale1" (rtos scale1))
  819.             (set_tile "scale2" (rtos scale2))
  820.             (if (= scale_ID 0) (mode_tile "delete_scale" 1))
  821.             (mode_tile "scale_ID" 2)
  822.             (setq last_focus "scale_ID")
  823.           )
  824.           (if last_focus (mode_tile last_focus 2))
  825.         )
  826.       )
  827.       (err "Child Dialog Box 'SCALE_D' Cannot Initialize" "delete_scale")
  828.     )
  829.   )
  830. )
  831.  
  832. (defun update_scale_file (/ fh t1)
  833.   (if (setq fh (open tbscales_path "w"))
  834.     (progn
  835.       (foreach t1 (cdr scale_list)
  836.         (progn 
  837.           (write-line (car t1) fh) 
  838.           (write-line (rtos (cadr t1) 2 10) fh) 
  839.           (write-line (rtos (caddr t1) 2 10) fh) 
  840.         )
  841.       )
  842.       (close fh)
  843.     )
  844.   )
  845. )
  846.  
  847. (defun valid_name (name)
  848.   (not (wcmatch name "*[] `#`@`.`?`*`~`[`,`'!%^&()+={}|`\\:;\"<>/]*"))
  849. )
  850.  
  851. (defun check_layer (/ t1)
  852.   (if (and (/= "" (setq t1 (get_tile "layer"))) (valid_name t1))
  853.     (progn
  854.       (setq tblayer (strcase t1))
  855.       (done_dialog 1)
  856.     )
  857.     (progn
  858.       (err 
  859.         (if (= t1 "")
  860.           "Press <Cancel> or specify a layer name."
  861.           "Layer name contains invalid characters."
  862.         )
  863.         "layer"
  864.       )
  865.       (mode_tile "layer" 2)
  866.     )
  867.   )
  868. )
  869.  
  870. (defun get_tblock (tblockss / d p il t1 t2 sp)
  871.   (setq p 0)
  872.   (if (< 1 (sslength tblockss))
  873.     (progn
  874.       (setq t1 0)
  875.       (setq il nil)
  876.       (repeat (sslength tblockss)
  877.         (setq il
  878.           (cons
  879.             (cdr (assoc '10 (entget (ssname tblockss t1))))
  880.             il
  881.           )
  882.         )
  883.         (setq t1 (1+ t1))
  884.       )
  885.       (setq il (reverse il))
  886.       (if
  887.         (not 
  888.           (setq sp 
  889.             (getpoint 
  890.               "\n \nPick Insertion Point of Title Block To Replace:  "
  891.             )
  892.           )
  893.         )
  894.         (setq sp (getvar "LASTPOINT"))
  895.       )
  896.       (setq d (distance (car il) sp))
  897.       (setq t1 1)
  898.       (while (< t1 (length il))
  899.         (if
  900.           (> d (setq t2 (distance (nth t1 il) sp)))
  901.           (progn
  902.             (setq d t2)
  903.             (setq p t1)
  904.           )
  905.         )
  906.         (setq t1 (1+ t1))
  907.       )
  908.     )
  909.   )                  
  910.   (ssname tblockss p)
  911. )
  912.  
  913. (defun get_tblayer (/ layer_list t1)
  914.   (if (and errflag (/= errflag "border"))
  915.     (mode_tile errflag 2)
  916.     (if (new_dialog "TBLAYER" dcl_id)
  917.       (progn
  918.         (start_list "existing")
  919.         (mapcar 'add_list 
  920.           (setq layer_list
  921.             (mapcar 
  922.               '(lambda (x) 
  923.                 (cdr (assoc '2 x))
  924.               ) 
  925.               (reverse (sort_list (get_table "LAYER") compare_name))
  926.             )
  927.           )
  928.         )
  929.         (end_list)
  930.         (action_tile "accept" "(check_layer)")
  931.         (action_tile "cancel" "(done_dialog 0)")
  932.         (action_tile "existing" 
  933.           (strcat
  934.             "(and (= 4 $reason)" 
  935.             " (set_tile \"layer\" (nth (atoi $value) layer_list))"
  936.             " (check_layer))"
  937.           )
  938.         )
  939.         (set_tile "layer" tblayer)
  940.         (start_dialog)
  941.         (set_tile "clayer" tblayer)
  942.         (if last_focus (mode_tile last_focus 2))
  943.       )
  944.       (set_tile "error" "Child Dialog Box 'TBLAYER' Cannot Initialize")
  945.     )
  946.   )
  947. )
  948.  
  949. (defun dismiss_dialog (retcode)
  950.   (if 
  951.     (and
  952.       errflag
  953.       (not (and (= retcode 3) (wcmatch errflag "?_ip")))
  954.       (not (and (= retcode 4) (= errflag "angle")))
  955.       (and (= retcode 2) (= errflag "border"))
  956.     )
  957.     (mode_tile errflag 2) 
  958.     (progn
  959.       (if (and errflag (/= errflag "border"))
  960.         (progn (setq last_focus errflag) (clear_err))
  961.       )
  962.       (done_dialog retcode)
  963.     )
  964.   )
  965. )
  966.  
  967.  
  968. ;*********************************************************
  969. ;*******************  MAIN PROGRAM  **********************
  970. ;*********************************************************
  971.  
  972.   (setq T (not nil))
  973.   (if 
  974.     (and 
  975.       (or 
  976.         (setq xdos_loaded (= 'EXSUBR (type dosdir))) 
  977.         (setq xdos_loaded 
  978.           (if (setq t1 (fpath "xdos_dt.exp")) 
  979.             (if (setq t2 (xload t1 nil)) 
  980.               t2 
  981.               (progn (xunload "xdos_dt") (xload t1 nil))
  982.             )
  983.           )
  984.         )
  985.       )
  986.       (cond 
  987.         ( (not *TBSCALES)
  988.           (setq tbscales_path (open_file "TBSCALES.TBD"))
  989.         )
  990.         ( (wcmatch *TBSCALES "*`.[Tt][Bb][Dd]")
  991.           (setq tbscales_path (open_file *TBSCALES))
  992.         )
  993.         ( (wcmatch *TBSCALES "~*`.*") 
  994.           (setq tbscales_path (open_file (strcat *TBSCALES ".TBD")))
  995.         )
  996.         ( T
  997.           (alert 
  998.             (strcat
  999.               "  Invalid extension specified in *TBSCALES   "
  1000.               "\n   For Predefined Scale Definition File."
  1001.               "\n\n     Using:  TBSCALES.TBD"
  1002.             )
  1003.           )
  1004.           (setq tbscales_path (open_file "TBSCALES.TBD"))
  1005.         )
  1006.       )    
  1007.       (setq dcl_id (if (setq t1 (fpath "INSTITLE.DCL")) (load_dialog t1)))
  1008.     ) 
  1009.     (progn
  1010.       (setq oldvar
  1011.         (list
  1012.           (getvar "CMDECHO")
  1013.           (getvar "ATTDIA")
  1014.           (getvar "ATTMODE")
  1015.           (getvar "ATTREQ")
  1016.           (getvar "REGENMODE")
  1017.           (getvar "EXPERT")
  1018.           (getvar "CLAYER")
  1019.           (getvar "LUPREC")
  1020.           (getvar "UNDOCTL")
  1021.           (dt_doscurdir)
  1022.         )
  1023.       )
  1024.       (setq olderr  *error*
  1025.             restore institlex
  1026.             *error* errexit
  1027.       )
  1028.       (setvar "CMDECHO" 0)
  1029.       (setvar "REGENMODE" 0)
  1030.       (setvar "EXPERT" 0)
  1031.       (setvar "ATTDIA" 1)
  1032.       (setvar "ATTMODE" 0)
  1033.       (setvar "ATTREQ" 0)
  1034.       (if (/= 1 (setq t1 (logand 3 (getvar "UNDOCTL"))))
  1035.         (progn
  1036.           (command "_UNDO") 
  1037.           (if (/= 0 t1) (command "_C")) 
  1038.           (command "_A")
  1039.         )
  1040.       )
  1041.       (terpri)
  1042.       (setq tblayer (if *TBLAYER *TBLAYER "TITLE"))
  1043.       (setq scale
  1044.         (if (and *DWGSCALE (numberp *DWGSCALE)) (/ 1.0 *DWGSCALE) 1.0)
  1045.       )
  1046.       (setq scale_list 
  1047.         (list (list "< Default >" (distof "1.0") (/ 1.0 scale)))
  1048.       )
  1049.       (setq tbd (open tbscales_path "r"))
  1050.       (while (setq t1 (read-line tbd))
  1051.         (setq scale_list
  1052.           (append 
  1053.             scale_list 
  1054.             (list 
  1055.               (list 
  1056.                 t1
  1057.                 (if (setq t1 (read-line tbd)) (atof t1) '1.0)
  1058.                 (if (setq t1 (read-line tbd)) (atof t1) '1.0)
  1059.               )
  1060.             )
  1061.           )
  1062.         )
  1063.       )
  1064.       (close tbd)
  1065.       (or
  1066.         (setq tblocks_found (ssget "X" '((0 . "INSERT") (-3 ("TBLOCK")))))
  1067.         (setq tblocks_found 
  1068.           (ssget "X" 
  1069.             (list 
  1070.               (cons 0 "INSERT") 
  1071.               (cons 8 (if *TBLAYER *TBLAYER "TITLE"))
  1072.             )
  1073.           )
  1074.         )
  1075.       )
  1076.       (setq ip            (get_default_ip tblocks_found)
  1077.             ia            '0.0
  1078.             pattern       "*.bdr"
  1079.             tbd           (if *DT_PATH *DT_PATH tbscales_path)
  1080.             bdr           ""
  1081.             dlg_retcode   6 
  1082.             last_focus    "border"
  1083.             scale1        '1.0
  1084.             scale2        (/ 1.0 scale)
  1085.             scale_ID      nil
  1086.             select_method (not nil)
  1087.       )         
  1088.       (setq tbd
  1089.         (progn
  1090.           (dt_dossetdrv (- (ascii (strcase tbd)) 64))
  1091.           (dt_dossetdir 
  1092.             (if 
  1093.               (and 
  1094.                 tbd 
  1095.                 (> (strlen tbd) 3) 
  1096.                 (= "\\" (substr tbd (strlen tbd) 1))
  1097.               )
  1098.               (substr tbd 1 (1- (strlen tbd)))
  1099.               tbd
  1100.             )
  1101.           )
  1102.         )
  1103.       )         
  1104.       (while (and (> dlg_retcode 1) (new_dialog "INSTITLE" dcl_id))
  1105.         (if tblocks_found
  1106.           (progn
  1107.             (mode_tile "replace" 0)
  1108.             (set_tile "replace" (if insert_method insert_method "0"))
  1109.           )
  1110.           (progn
  1111.             (mode_tile "replace" 1)
  1112.             (set_tile "replace" "0")
  1113.           )
  1114.         )
  1115.         (set_tile "angle" (angtos ia))
  1116.         (set_tile "x_ip" (rtos (car ip) 2))
  1117.         (set_tile "y_ip" (rtos (cadr ip) 2))
  1118.         (set_tile "z_ip" (rtos (caddr ip) 2))
  1119.         (set_tile "path" tbd)
  1120.         (set_tile "border" bdr)
  1121.         (set_tile "clayer" tblayer)
  1122.         (if (findfile (strcat tbd "\\" bdr)) (clear_err) (err "" "border"))
  1123.         (set_tile "pattern" pattern)
  1124.         (start_list "scale_ID")
  1125.         (foreach t1 scale_list (add_list (car t1)))
  1126.         (end_list)
  1127.         (set_tile 
  1128.           "scale_ID" 
  1129.           (itoa 
  1130.             (if scale_ID scale_ID (setq scale_ID (find_scale scale)))
  1131.           )
  1132.         )
  1133.         (if (and select_method (> scale_ID 0))
  1134.           (progn
  1135.             (mode_tile "edit_scale" 0)
  1136.             (mode_tile "delete_scale" 0)
  1137.           )
  1138.         )
  1139.         (set_tile "scale_select_method" (if select_method "1" "0"))
  1140.         (mode_tile "scale_ID" (if select_method '0 '1))
  1141.         (mode_tile "scale1" (if select_method '1 '0))
  1142.         (mode_tile "scale2" (if select_method '1 '0))
  1143.         (set_tile "scale1" (rtos scale1))
  1144.         (set_tile "scale2" (rtos scale2))
  1145.         (update_tbpath)      
  1146.         (update_tbfile)
  1147.         (action_tile "help" "(get_help)")
  1148.         (action_tile "tbfile" "(put_border $value)")
  1149.         (action_tile "tbdir" "(if (= 4 $reason) (change_path $value))")
  1150.         (action_tile "add_scale" "(add_scale)")
  1151.         (action_tile "edit_scale" "(edit_scale)")
  1152.         (action_tile "delete_scale" "(delete_scale)")
  1153.         (action_tile "layer" "(get_tblayer)")
  1154.         (action_tile "preview" 
  1155.           (strcat
  1156.             "(if (= bdr \"\")" 
  1157.               " (progn"
  1158.                 " (err \"You Must Specify a Border.\" \"border\")" 
  1159.                 " (mode_tile \"border\" 2)"
  1160.               ")"
  1161.               " (dismiss_dialog 2)"
  1162.             ")"
  1163.           )
  1164.         )
  1165.         (action_tile "pick_ip" "(dismiss_dialog 3)")
  1166.         (action_tile "digitize_angle" "(dismiss_dialog 4)")
  1167.         (action_tile "accept" "(get_values)")
  1168.         (action_tile "cancel" "(done_dialog 0)")
  1169.         (foreach t1
  1170.           '(  "pattern"   "border"    "scale1"    "scale2"
  1171.               "scale_ID"  "x_ip"      "y_ip"      "z_ip"     
  1172.               "angle"     "scale_select_method"   "replace"
  1173.           )
  1174.           (action_tile t1 "(dlg_act $key $reason $value)")
  1175.         )
  1176.         (if last_focus (mode_tile last_focus 2))
  1177.         (setq dlg_retcode (start_dialog))
  1178.         (cond
  1179.           (
  1180.             (= 2 dlg_retcode)
  1181.             (prompt "\nPress any key to continue\n")
  1182.             (command 
  1183.               "_UNDO"
  1184.               "_G"
  1185.               "_LAYER"
  1186.               (if
  1187.                 (tblsearch "LAYER" (if tblayer tblayer "TITLE"))
  1188.                 "_S"
  1189.                 "_M"
  1190.               )
  1191.               (if tblayer tblayer "TITLE")
  1192.               ""
  1193.               "_INSERT"
  1194.               (strcat (substr bdr 1 (- (strlen bdr) 4)) "=" tbd "\\" bdr)
  1195.               "_rotate"
  1196.               (rtd ia)
  1197.               "_scale"
  1198.               (/ 1.0 scale)
  1199.               ip
  1200.               (grread)
  1201.               (grread 1)
  1202.               cancel
  1203.               "_UNDO"
  1204.               "_E"
  1205.               "_UNDO"
  1206.               "1"
  1207.             )  
  1208.             (redraw)
  1209.             (princ "\nReturning to Dialog Box\n \n ")
  1210.           )
  1211.           (
  1212.             (= 3 dlg_retcode)
  1213.             (if (and tbd bdr (findfile (strcat tbd "\\" bdr)))
  1214.               (progn
  1215.                 (prompt "\nPick the Title Block Insertion Point: ")
  1216.                 (command 
  1217.                   "_UNDO"
  1218.                   "_G"
  1219.                   "_INSERT"
  1220.                   (strcat (substr bdr 1 (- (strlen bdr) 4)) "=" tbd "\\" bdr)
  1221.                   "_rotate"
  1222.                   (rtd ia)
  1223.                   "_pscale"
  1224.                   (/ 1.0 scale)
  1225.                   pause
  1226.                   cancel
  1227.                 )
  1228.                 (setq ip (getvar "LASTPOINT"))
  1229.                 (command
  1230.                   "_UNDO"
  1231.                   "_E"
  1232.                   "_UNDO"
  1233.                   "1"
  1234.                 )
  1235.                 (redraw)
  1236.               )
  1237.               (setq ip (getpoint "\nPick the Title Block Insertion Point:  "))
  1238.             )
  1239.             (princ "\nInsertion Point Selected\n \n ")
  1240.             (set_tile "x_ip" (rtos (car ip) 2))
  1241.             (set_tile "y_ip" (rtos (cadr ip) 2))
  1242.             (set_tile "z_ip" (rtos (caddr ip) 2))
  1243.           )
  1244.           (
  1245.             (= 4 dlg_retcode)
  1246.             (setq ia
  1247.               (getorient "\nPick the Title Block Rotation Angle:  ")
  1248.             )
  1249.             (terpri)
  1250.             (set_tile "angle" (angtos ia))
  1251.           )
  1252.           (
  1253.             (= 1 dlg_retcode)
  1254.             (setq *TBLAYER tblayer)
  1255.             (setq scale     (/ 1.0 scale)
  1256.                   *DWGSCALE scale
  1257.             )
  1258.             (if (setq t1 (fpath "TBLOCK.LSP")) (load t1))
  1259.             (setq tblocks_found
  1260.               (if (and tblocks_found (= "1" insert_method))
  1261.                 (get_tblock tblocks_found)
  1262.                 nil
  1263.               )
  1264.             )
  1265.             (if 
  1266.               (setq t1 
  1267.                 (fpath 
  1268.                   (strcat 
  1269.                     tbd 
  1270.                     "\\" 
  1271.                     (substr bdr 1 (- (strlen bdr) 4)) 
  1272.                     ".lsp"
  1273.                   )
  1274.                 )
  1275.               )
  1276.               (load t1)
  1277.             )
  1278.             (if (listp SETSCALES) (SETSCALES scale))
  1279.             (terpri)
  1280.             (graphscr)
  1281.             (command 
  1282.               "_UNDO"
  1283.               "_G"
  1284.               "_LAYER"
  1285.               (if
  1286.                 (tblsearch "LAYER" (if *TBLAYER *TBLAYER "TITLE"))
  1287.                 "_S"
  1288.                 "_M"
  1289.               )
  1290.               (if *TBLAYER *TBLAYER "TITLE")
  1291.               ""
  1292.             )
  1293.             (command "_INSERT"
  1294.               (strcat (substr bdr 1 (- (strlen bdr) 4)) "=" tbd "\\" bdr)
  1295.               cancel
  1296.             )
  1297.             (prompt "\n \nResolving Title Block Attribute Values...")
  1298.             (setq ca 
  1299.               (cdr 
  1300.                 (assoc 
  1301.                   '-2 
  1302.                   (tblsearch "BLOCK" (substr bdr 1 (- (strlen bdr) 4)))
  1303.                 )
  1304.               )
  1305.             )
  1306.             (while
  1307.               (and ca (setq t1 (entget ca)))
  1308.               (and
  1309.                 (= "ATTDEF" (cdr (assoc '0 t1)))
  1310.                 (progn
  1311.                   (setq t2 nil)
  1312.                   (if 
  1313.                     (and
  1314.                       tblocks_found
  1315.                       (setq t2 
  1316.                         (get_attrib_value tblocks_found (cdr (assoc '2 t1)))
  1317.                       )
  1318.                     )
  1319.                     (setq t2
  1320.                       (entmod
  1321.                         (subst
  1322.                           (cons '1 t2)
  1323.                           (assoc '1 t1)
  1324.                           t1
  1325.                         )
  1326.                       )
  1327.                     )
  1328.                   )
  1329.                   (if t2 (setq t1 t2) T)
  1330.                 )
  1331.                 (and 
  1332.                   (= "=" (substr (cdr (assoc '1 t1)) 1 1))
  1333.                   (/= "=" (substr (cdr (assoc '1 t1)) 2 1))
  1334.                 )
  1335.                 (entmod
  1336.                   (subst
  1337.                     (cons '1 (eval (read (substr (cdr (assoc '1 t1)) 2))))
  1338.                     (assoc '1 t1)
  1339.                     t1
  1340.                   )
  1341.                 )
  1342.               )
  1343.               (setq ca (entnext ca))
  1344.             )
  1345.             (prompt "\n \nAttribute Values Updated\n ")
  1346.             (if tblocks_found (command "_ERASE" tblocks_found ""))
  1347.             (setvar "ATTREQ" 1)
  1348.             (regapp "TBLOCK")
  1349.             (command "_INSERT"
  1350.               (substr bdr 1 (- (strlen bdr) 4))
  1351.               "_rotate"
  1352.               (rtd ia)
  1353.               "_scale"
  1354.               scale
  1355.               ip
  1356.             )  
  1357.             (setq *TBATTRIB (setq ca (entlast)))
  1358.             (if (/= 0 (cdr (assoc '66 (entget ca))))
  1359.               (progn
  1360.                 (while
  1361.                   (and (setq ca (entnext ca)) (setq t1 (entget ca)))
  1362.                   (and
  1363.                     (= "ATTRIB" (cdr (assoc '0 t1)))
  1364.                     (= "==" (substr (cdr (assoc '1 t1)) 1 2))
  1365.                     (entmod
  1366.                       (append
  1367.                         (subst
  1368.                           (cons '1 
  1369.                             (eval 
  1370.                               (read (substr (setq t2 (cdr (assoc '1 t1))) 3))
  1371.                             )
  1372.                           )
  1373.                           (assoc '1 t1)
  1374.                           t1
  1375.                         )
  1376.                         (list (list -3 (list "TBLOCK" (cons 1000 t2))))
  1377.                       )
  1378.                     )
  1379.                   )
  1380.                 )
  1381.                 (setvar "ATTMODE" 1)
  1382.               )
  1383.             )
  1384.             (entmod
  1385.               (append 
  1386.                 (entget (entlast)) 
  1387.                 (list (list '-3 (list "TBLOCK" (cons 1071 scale))))
  1388.               )
  1389.             )
  1390.             (command "_UNDO" "_E")
  1391.           )
  1392.         )
  1393.       )
  1394.       (unload_dialog dcl_id)
  1395.       (restore)
  1396.     )
  1397.     (alert 
  1398.       (cond 
  1399.         ( xdos_loaded
  1400.           (strcat 
  1401.             "Dialog Box Definition File 'INSTITLE.DCL' not Found"
  1402.             "\n                Cannot Continue!"
  1403.           )
  1404.         )
  1405.         ( tbscales_path
  1406.           (strcat 
  1407.             " ADS Application 'XDOS_DT.EXP' not Found "
  1408.             "\n           Cannot Continue!"
  1409.           )
  1410.         )
  1411.         ( T
  1412.           (strcat
  1413.             "Illegal Path for Predefined Scale Definition File"
  1414.             "\n               Cannot Continue!"
  1415.           )
  1416.         )
  1417.       )
  1418.     )
  1419.   )
  1420. )
  1421.